<?php
/**
 * Created by PhpStorm.
 * User: cc
 * Date: 2023/7/31
 * Time: 2:53 PM
 */

namespace app\astrologer\controller\v5;

use app\astrologer\controller\AstrAuth;
use app\common\cachemodel\AppConfig;
use app\common\cachemodel\zlcr3\Zlcr3ConsultAccount;
use app\common\cachemodel\zlcr3\Zlcr3ConsultModifyPriceRecord;
use app\common\cachemodel\ZlcrAstr;
use app\common\cachemodel\ZlcrAstrAccount;
use app\common\cachemodel\ZlcrAstrExerciseRecord;
use app\common\cachemodel\ZlcrAstrInfo;
use think\Env;
use think\response\Json;

class User extends AstrAuth
{

    /**
     * 个人中心
     * @return Json
     * @throws \app\common\lib\exception\ApiException
     */
    public function info()
    {
        $host = Env::get('host.photo');
        $accountInfo = (new ZlcrAstrAccount())->getAstrAccountInfo($this->astrInfo['id'], ['balance']);
        $authStatus = $this->astrInfo['auth_status'];
        $passList = [
            0 => $authStatus['custom_report'],
            1 => $authStatus['question_answer_astr'],
            2 => $authStatus['question_answer_dice'],
            3 => $authStatus['question_answer_tarot'],
        ];

        if ($this->astrInfo['uid'])
        {
            $userInfo = (new \app\common\model\User())->getUserinfo(['id' => $this->astrInfo['uid']]);
        }

        if ($this->isConsultAstro)
        {
            $level = $this->consultAccountInfo['level'];
        }

        return show(config('code.success'), '', [
            'id' => $this->astrInfo['id'],
            'name' => $this->astrInfo['nickname'],
            'avatar' => $this->astrInfo['avatar'] ? $host . $this->astrInfo['avatar'] : '',
            'balance' => $accountInfo['balance'],
            'exam_status' => array_sum($passList) === 1 ? '还有考核未通过' : '全部通过',
            'is_profile_completed' => isset($this->astrInfo['extend']['is_complete_information']) ? 1 : 0,
            'pass_list' => $passList,
            'uen' => $userInfo['uen'] ?? '',
            'level' => $level ?? 0,
        ]);
    }

    /**
     * 主页
     * @return Json
     * @throws \Exception
     */
    public function homePage()
    {
        $res = (new ZlcrAstr())->homePage($this->astrInfo, 2);
        unset($res['status']);
        $res['level'] = $this->isConsultAstro ? $this->consultAccountInfo['level'] : 0;

        return show(config('code.success'), '', $res);
    }

    /**
     * 我的-》能力分记录-》连线单价
     * @return Json
     * @throws \Exception
     */
    public function rtcPriceInfo()
    {
        $consultModel = new Zlcr3ConsultAccount();
        if ($this->consultAccountInfo['level'] < 6)
        {   // 连线等级 小于6
            $nextLevelScore = $consultModel->astrLevelMinScore[$this->consultAccountInfo['level'] + 1];
            // $nextLevelScore = $consultModel->astrLevelMinScore[$this->consultAccountInfo['level'] + 1] - $this->consultAccountInfo['level_score'];
            $allScore = $consultModel->astrLevelMinScore[$this->consultAccountInfo['level'] + 1] - $consultModel->astrLevelMinScore[$this->consultAccountInfo['level']];
            $score = $this->consultAccountInfo['level_score'] - $consultModel->astrLevelMinScore[$this->consultAccountInfo['level']];
            $upgradeProgress = floor($score / $allScore * 100) / 100;
        } else
        {
            $nextLevelScore = $this->consultAccountInfo['level_score'];
        }
        // 预计收益
        $price = sprintf('%.2f', $this->consultAccountInfo['price'] * $consultModel->getPercent($this->consultAccountInfo['percent'], 1) / 10);

        $modifyPriceData = $consultModel->rtcModifyPriceData;

        if ($this->consultAccountInfo['level'] > 1)
        {
            if (isset($this->consultAccountInfo['extend']['last_modify_price_time']) && $this->request->time() - $this->consultAccountInfo['extend']['last_modify_price_time'] < 86400)
            {   // 连线价格修改时间在一天之内
                $btnType = 1;
                $btnName = '3小时后可修改';
            } else
            {   // 连线价格修改时间超过一天
                $btnType = 2;
                $btnName = '修改价格';
            }
        } else
        {
            $btnType = 0;
            $btnName = '';
        }
        $minPrice = $modifyPriceData[$this->consultAccountInfo['level']]['min_price'];
        $maxPrice = $modifyPriceData[$this->consultAccountInfo['level']]['max_price'];

        return show(config('code.success'), 'success', [
            'level' => $this->consultAccountInfo['level'],
            'score' => $this->consultAccountInfo['level_score'],
            'next_level_score' => $nextLevelScore ?? 0,
            'upgrade_progress' => $upgradeProgress ?? 1, // 升级进度
            'list' => [
                [
                    'title' => '当前连线价格：',
                    'value' => "{$this->consultAccountInfo['price']}币/分钟",
                    'percent' => 0.25,
                    'btn_type' => $btnType,
                    'btn_name' => $btnName,
                    'des' => "当前分成比例：25%，预估每分钟收益：{$price}元/分钟",
                    'min_price' => $minPrice,
                    'max_price' => $maxPrice,
                    'current_price' => (int)$this->consultAccountInfo['price'],
                ],
                [
                    'title' => '准有好事问答分成比例：',
                    'value' => '25%',
                    'percent' => '',
                    'btn_type' => 3,
                    'btn_name' => '查看规则',
                    'des' => '',
                    'min_price' => 0,
                    'max_price' => 0,
                    'current_price' => 0,
                ],
            ],
        ]);
    }

    /**
     * 连线咨询 单价改价
     */
    public function consultModifyPrice()
    {
        $price = input('price', 0);
        if (!$price)
        {
            return show(config('code.error'), '请求异常，请稍后再试～');
        }
        if (!$this->isConsultAstro)
        {
            return show(config('code.error'), '不是咨询师，无法修改价格');
        }
        if (!in_array($this->consultAccountInfo['level'], [2, 3, 4, 5, 6], true))
        {
            return show(config('code.error'), '操作失败，当前等级不支持修改价格');
        }

        $consultModel = new Zlcr3ConsultAccount();
        $modifyPriceData = $consultModel->rtcModifyPriceData;

        if ($price < $modifyPriceData[$this->consultAccountInfo['level']]['min_price'])
        {
            return show(config('code.error'), '修改价格不能低于' . $modifyPriceData[$this->consultAccountInfo['level']]['min_price'] . '元/分钟');
        }
        if ($price > $modifyPriceData[$this->consultAccountInfo['level']]['max_price'])
        {
            return show(config('code.error'), '修改价格不能高于' . $modifyPriceData[$this->consultAccountInfo['level']]['max_price'] . '元/分钟');
        }

        $lastModifyPriceTime = $this->consultAccountInfo['extend']['last_modify_price_time'] ?? 0;

        $time = 86400 - ($this->request->time() - $lastModifyPriceTime);
        if ($time > 0)
        {
            if ($time > 3600)
            {
                $t = ceil($time / 3600) . '小时';
            } else
            {
                $t = ceil($time / 60) . '分钟';
            }
            return show(config('code.error'), '修改价格失败，请' . $t . '后再试');
        }
        $extend = $this->consultAccountInfo['extend'];
        $extend['last_modify_price_time'] = $this->request->time(); // 记录最近更新时间
        $update = [
            'price' => $price,
            'extend' => json_encode($extend, JSON_UNESCAPED_UNICODE),
        ];
        $consultModel->updateData($this->astrInfo['id'], $update);

        (new Zlcr3ConsultModifyPriceRecord())->SaveData([
            'astr_id' => $this->astrInfo['id'],
            'level' => $this->consultAccountInfo['level'],
            'price' => $price,
            'create_time' => $this->request->time(),
        ]);

        return show(config('code.success'), '改价成功');
    }

    /**
     * 获取考试状态
     */
    public function getAssessmentData()
    {
        if ($this->astrInfo['check_status'] !== 40)
        {
            $astroConfig = (new AppConfig())->configInfo('astro_app');
            if (isset($astroConfig['examine_join_status']) && $astroConfig['examine_join_status'])
            {
                return show(config('code.error'), '考试入驻暂停，请你谅解。');
            }
        }

        $imgHost = Env::get('host.photo');
        $type = input('type/d', 0); // 0=>注册场景 1=>个人中心认证 2=>问答相关认证 3=>定制报告相关认证

        $astrInfo = (new ZlcrAstrInfo())->getInfoById($this->astrInfo['id'], 'id');
        $data = [
            'msg_title' => $type === 1 ? '' : '恭喜您注册成功',
            'msg_des' => $type === 1 ? '' : '恭喜您成功注册占星平台，完成以下流程后即可正式入驻占星平台',
            'list' => [],
            'is_complete_info' => $astrInfo ? 1 : 0,
        ];
        $is_pass_all = true;//是否通过了所有考试

        $authStatus = $this->astrInfo['auth_status'];
        $astrAnswerModel = new ZlcrAstrExerciseRecord();
        if (in_array($type, [0, 1, 2], true))
        {
            if ($authStatus['question_answer_astr'] === 0 || $this->astrInfo['check_status'] < 30)
            {   // 获取用户当前答题状态信息
                $astrAnswerInfo = $astrAnswerModel->getExerciseInfo($this->astrInfo['id'], 3);   // 1=>定制报告 2=>问答三合一 3=>问答星盘 4=>问答骰子 5=>问答卡牌
                $res = $astrAnswerModel->getExerciseRes2($astrAnswerInfo);

                $questionAnswerAstrStatus = $res[1]['status'];  // 考试状态 // -1=>不可以考试（前端不可点击）、0=>可以考试（前端可以点击）、1=>未通过、2=>已通过、3=》审核中
                $questionAnswerAstrTips = $res[1]['tips'];
                $questionAnswerAstr2Status = $res[2]['status'];  // 考试状态 // -1=>不可以考试（前端不可点击）、0=>可以考试（前端可以点击）、1=>未通过、2=>已通过、3=》审核中
                $questionAnswerAstr2Tips = $res[2]['tips'];
                $is_pass_all = false;
            }
            if ($authStatus['question_answer_dice'] === 0 || $this->astrInfo['check_status'] < 30)
            {   // 获取用户当前答题状态信息
                $astrAnswerInfo = $astrAnswerModel->getExerciseInfo($this->astrInfo['id'], 4);   // 1=>定制报告 2=>问答三合一 3=>问答星盘 4=>问答骰子 5=>问答卡牌
                $res = $astrAnswerModel->getExerciseRes2($astrAnswerInfo);

                $questionAnswerDiceStatus = $res[1]['status'];  // 考试状态
                $questionAnswerDiceTips = $res[1]['tips'];  //
                $questionAnswerDice2Status = $res[2]['status'];  // 考试状态
                $questionAnswerDice2Tips = $res[2]['tips'];  //
                $is_pass_all = false;
            }
            if ($authStatus['question_answer_tarot'] === 0 || $this->astrInfo['check_status'] < 30)
            {   // 获取用户当前答题状态信息
                $astrAnswerInfo = $astrAnswerModel->getExerciseInfo($this->astrInfo['id'], 5);   // 1=>定制报告 2=>问答三合一 3=>问答星盘 4=>问答骰子 5=>问答卡牌
                $res = $astrAnswerModel->getExerciseRes2($astrAnswerInfo);
                $questionAnswerTarotStatus = $res[1]['status']; // 考试状态
                $questionAnswerTarotTips = $res[1]['tips']; //
                $questionAnswerTarot2Status = $res[2]['status']; // 考试状态
                $questionAnswerTarot2Tips = $res[2]['tips']; //
                $is_pass_all = false;
            }

            $questionAnswerMergeIsPassed = $authStatus['question_answer_astr'] === 1 && $authStatus['question_answer_dice'] === 1 && $authStatus['question_answer_tarot'] === 1 ? 1 : 0;
            if ($questionAnswerMergeIsPassed === 0 || $this->astrInfo['check_status'] < 30)
            {
                $astrAnswerInfo = $astrAnswerModel->getExerciseInfo($this->astrInfo['id'], 2);   // 1=>定制报告 2=>问答三合一 3=>问答星盘 4=>问答骰子 5=>问答卡牌
                $res = $astrAnswerModel->getExerciseRes2($astrAnswerInfo);
                $questionAnswerMergeStatus = $res[1]['status']; // 考试状态
                $questionAnswerMergeTips = $res[1]['tips']; //
                $questionAnswerMerge2Status = $res[2]['status']; // 考试状态
                $questionAnswerMerge2Tips = $res[2]['tips']; //
            }

            $data['list'][] = [
                'title' => '问答技能测试考核',
                'list' => [
                    [
                        'type' => 2,
                        'img' => $imgHost . '/mini/astrologer/test/1.png',
                        'name' => '3合1准了问答综合技能测试',
                        'desc' => '您需要熟练掌握星盘、占星骰子、卡牌的相关知识，能独立输出自己的观点。',
                        'tips' => $questionAnswerMergeIsPassed && $this->astrInfo['check_status'] >= 30 ? '已获得所有问答的接单资格' : '通过后可获得所有问答的接单资格',
                        'is_passed' => $questionAnswerMergeIsPassed && $this->astrInfo['check_status'] >= 30 ? 1 : 0,
                        'list' => [
                            [
                                'id' => 1,
                                'title' => '选择题',
                                'status' => $questionAnswerMergeStatus ?? 2,  // 考试状态 // -1=>不可以考试（前端不可点击）、0=>可以考试（前端可以点击）、1=>未通过、2=>已通过、3=》审核中
                                'tips' => $questionAnswerMergeTips ?? '',
                                'content' => [
                                    '每个人每类测评每天只有1次测评机会，未通过则24小时后重试。',
                                    '考试限时60分钟内完成，如果测试中途退出，结果保留，可继续进行测试。',
                                    '共60道题，答对50道题通过考试，每道题限时1分钟内完成，超时自动判错，通过后即可申请基础面试考核。',
                                ],
                            ], [
                                'id' => 3,
                                'title' => '基础面试',
                                'status' => $questionAnswerMerge2Status ?? 2,  // 考试状态 // -1=>不可以考试（前端不可点击）、0=>可以考试（前端可以点击）、1=>未通过、2=>已通过、3=》审核中
                                'tips' => $questionAnswerMerge2Tips ?? '',
                                'content' => [],
                            ],
                        ],
                    ],
                    [
                        'type' => 3,
                        'img' => $imgHost . '/mini/astrologer/test/2.png',
                        'name' => '咨询师测评-准了星盘问答',
                        'desc' => '您需要熟练掌握星盘相关知识，能独立输出自己的观点。',
                        'tips' => $authStatus['question_answer_astr'] === 1 && $this->astrInfo['check_status'] >= 30 ? '已获得星盘问答的接单资格' : '通过后可获得星盘问答的接单资格',
                        'is_passed' => $authStatus['question_answer_astr'] === 1 && $this->astrInfo['check_status'] >= 30 ? 1 : 0 ? 1 : 0,
                        'list' => [
                            [
                                'id' => 1,
                                'title' => '选择题',
                                'status' => $questionAnswerAstrStatus ?? 2, // 考试状态 // -1=>不可以考试（前端不可点击）、0=>可以考试（前端可以点击）、1=>未通过、2=>已通过、3=》审核中
                                'tips' => $questionAnswerAstrTips ?? '',
                                'content' => [
                                    '每个人每类测评每天只有1次测评机会，未通过则24小时后重试。',
                                    '考试限时40分钟内完成，如果测试中途退出，结果保留，可继续进行测试。',
                                    '共30道题，答对25道题通过考试，每道题限时1分钟内完成，超时自动判错，通过后即可申请基础面试考核。',
                                ],
                            ], [
                                'id' => 3,
                                'title' => '基础面试',
                                'status' => $questionAnswerAstr2Status ?? 2,  // 考试状态 // -1=>不可以考试（前端不可点击）、0=>可以考试（前端可以点击）、1=>未通过、2=>已通过、3=》审核中
                                'tips' => $questionAnswerAstr2Tips ?? '',
                                'content' => [],
                            ],
                        ],
                    ],
                    [
                        'type' => 4,
                        'img' => $imgHost . '/mini/astrologer/test/3.png',
                        'name' => '咨询师测评-准了骰子问答',
                        'desc' => '您需要熟练掌握占星骰子相关知识，能独立输出自己的观点。',
                        'tips' => $authStatus['question_answer_dice'] === 1 && $this->astrInfo['check_status'] >= 30 ? '已获得骰子问答的接单资格' : '通过后可获得骰子问答的接单资格',
                        'is_passed' => $authStatus['question_answer_dice'] === 1 && $this->astrInfo['check_status'] >= 30 ? 1 : 0 ? 1 : 0,
                        'list' => [
                            [
                                'id' => 1,
                                'title' => '选择题',
                                'status' => $questionAnswerDiceStatus ?? 2,// 考试状态 // -1=>不可以考试（前端不可点击）、0=>可以考试（前端可以点击）、1=>未通过、2=>已通过、3=》审核中
                                'tips' => $questionAnswerDiceTips ?? '',
                                'content' => [
                                    '每个人每类测评每天只有1次测评机会，未通过则24小时后重试。',
                                    '考试限时40分钟内完成，如果测试中途退出，结果保留，可继续进行测试。',
                                    '共30道题，答对25道题通过考试，每道题限时1分钟内完成，超时自动判错，通过后即可申请基础面试考核。',
                                ],
                            ], [
                                'id' => 3,
                                'title' => '基础面试',
                                'status' => $questionAnswerDice2Status ?? 2,  // 考试状态 // -1=>不可以考试（前端不可点击）、0=>可以考试（前端可以点击）、1=>未通过、2=>已通过、3=》审核中
                                'tips' => $questionAnswerDice2Tips ?? '',
                                'content' => [],
                            ],
                        ],
                    ],
                    [
                        'type' => 5,
                        'img' => $imgHost . '/mini/astrologer/test/4.png',
                        'name' => '咨询师测评-准了卡牌问答',
                        'desc' => '您需要熟练掌握卡牌相关知识，能独立输出自己的观点。',
                        'tips' => $authStatus['question_answer_tarot'] === 1 && $this->astrInfo['check_status'] >= 30 ? '已获得卡牌问答的接单资格' : '通过后可获得卡牌问答的接单资格',
                        'is_passed' => $authStatus['question_answer_tarot'] === 1 && $this->astrInfo['check_status'] >= 30 ? 1 : 0 ? 1 : 0,
                        'list' => [
                            [
                                'id' => 1,
                                'title' => '选择题',
                                'status' => $questionAnswerTarotStatus ?? 2,// 考试状态 // -1=>不可以考试（前端不可点击）、0=>可以考试（前端可以点击）、1=>未通过、2=>已通过、3=》审核中
                                'tips' => $questionAnswerTarotTips ?? '',
                                'content' => [
                                    '每个人每类测评每天只有1次测评机会，未通过则24小时后重试。',
                                    '考试限时40分钟内完成，如果测试中途退出，结果保留，可继续进行测试。',
                                    '共30道题，答对25道题通过考试，每道题限时1分钟内完成，超时自动判错，通过后即可申请基础面试考核。',
                                ],
                            ], [
                                'id' => 3,
                                'title' => '基础面试',
                                'status' => $questionAnswerTarot2Status ?? 2,  // 考试状态 // -1=>不可以考试（前端不可点击）、0=>可以考试（前端可以点击）、1=>未通过、2=>已通过、3=》审核中
                                'tips' => $questionAnswerTarot2Tips ?? '',
                                'content' => [],
                            ],
                        ],
                    ],
                ],
            ];
        }

        if (in_array($type, [0, 1, 3], true))
        {
            if ($authStatus['custom_report'] === 0 || $this->astrInfo['check_status'] < 30)
            {   // 获取用户当前答题状态信息
                $astrAnswerInfo = $astrAnswerModel->getExerciseInfo($this->astrInfo['id'], 1);   // 1=>定制报告 2=>问答三合一 3=>问答星盘 4=>问答骰子 5=>问答卡牌

                $res = $astrAnswerModel->getExerciseRes2($astrAnswerInfo);
                $customReport1Status = $res[1]['status']; // 考试状态
                $customReport1Tips = $res[1]['tips']; //
                $customReport2Status = $res[2]['status']; // 考试状态
                $customReport2Tips = $res[2]['tips']; //
                $is_pass_all = false;
            }

            $data['list'][] = [
                'title' => '定制报告技能测试考核',
                'list' => [
                    [
                        'type' => 1,
                        'img' => $imgHost . '/mini/astrologer/test/5.png',
                        'name' => '占星师测评-准了定制报告',
                        'desc' => '您需要熟练掌握星盘相关知识，能独立输出自己的观点。',
                        'tips' => $authStatus['custom_report'] === 1 && $this->astrInfo['check_status'] >= 30 ? '已获得定制报告及星盘问答接单资格' : '通过后获得定制报告及星盘问答接单资格',
                        'is_passed' => $authStatus['custom_report'] === 1 && $this->astrInfo['check_status'] >= 30 ? 1 : 0 ? 1 : 0,
                        'list' => [
                            [
                                'id' => 1,
                                'title' => '选择题',
                                'status' => $customReport1Status ?? 2,
                                'tips' => $customReport1Tips ?? '',
                                'content' => [
                                    '选择题考核共40题，分单选及多选，答对35题则考核成功进入基础面试考核',
                                    '选择题考核每题回答时间为60秒，若超时则当前题默认0分，自动进入下一道题',
                                    '选择题考核总时长为1小时，若超过规定时间未提交则所有超时的题，自动设置为0分',
                                    '考核如不通过则从考试结束时间开始计算间隔24小时才可继续重新考核',
                                ],
                            ],
                            // [
                            //     'id' => 2,
                            //     'title' => '简答题',
                            //     'status' => $customReport2Status ?? 2,
                            //     'tips' => $customReport2Tips ?? '',
                            //     'content' => [
                            //         '占星师开始笔试考核后需要在特定星盘下回答指定问题，回复字数以及占星技法不限',
                            //         '笔试考核总计时间为4小时，点击开始笔试考核后开始计时。若超过指定时间未提交则自动设置为0分',
                            //         '提交回复后请占星师耐心等待，官方审核人员快马加鞭将在7个工作日内给予短信回复通知，请留意手机短信',
                            //         '通过笔试考核后则可继续登录填写资料完成后续入驻流程'
                            //     ],
                            // ],
                            [
                                'id' => 3,
                                'title' => '基础面试',
                                'status' => $customReport2Status ?? 2,
                                'tips' => $customReport2Tips ?? '',
                                'content' => [],
                            ],
                        ],
                    ],
                ],
            ];
        }

        if ($type === 1)
        {//个人中心点击认证考试
            if ($is_pass_all)
            {//已通过全部考试
                $data['msg_title'] = '';
                $data['msg_des'] = '';
            } else
            {//未通过全部考试，顶部的提示
                $data['msg_title'] = '你还有未通过的考核测试';
                $data['msg_des'] = '你可以选择一下考核测试，获得相应的接单资格';
            }
        }

        return show(200, '请求成功', $data);
    }

    /**
     * 获取咨询师等级信息
     * 注意：用于能力分记录页面，有连线咨询资格的时候，那么展示“连线单价”tab，没有 则不显示 “连线单价” tab；
     */
    public function getUserLevelInfo()
    {
        $apiHost = Env::get('host.domain');
        $imgHost = Env::get('host.photo');
        $nowTime = time();
        $astrModel = new ZlcrAstr();

        $authStatus = $this->astrInfo['auth_status'];
        $data = [];
        $hint = '';//顶部提示

        if ($authStatus['custom_report'] === 1)
        {   // 定制报告
            $astrLevel = abs($this->astrInfo['astr_level']);
            $data[] = [
                'type' => 1,
                'title' => '准了定制报告能力分',
                'img' => $imgHost . '/mini/astrologer/test/1.png',
                'grade' => $this->astrInfo['astro_grade'],
                'level_name' => $astrModel->astrLevelName2[1][$astrLevel],
                'proportion' => ($astrModel->astrLevelProportion[$astrLevel] * 100) . '%',
                'protocol_url' => $apiHost . '/web/rule_astrologer',
            ];
        } else
        {
            $hint = '准了定制报告';
        }

        if ($authStatus['question_answer_astr'] === 1)
        {   // 问答星盘
            $astro2Level = abs($this->astrInfo['astro2_level']);
            $data[] = [
                'type' => 2,
                'title' => '准了问答-占星能力分',
                'img' => $imgHost . '/mini/astrologer/test/1.png',
                'grade' => $this->astrInfo['astro2_grade'],
                'level_name' => $astrModel->astrLevelName2[2][$astro2Level],
                'proportion' => ($astrModel->getAstrQuestionAnswerProportion($nowTime, 1, $astro2Level) * 100) . '%',
                'protocol_url' => $apiHost . '/web/rule_astro_grade',
            ];
        } else
        {
            if ($hint)
            {
                $hint .= '、';
            }
            $hint .= '准了问答星盘';
        }

        if ($authStatus['question_answer_tarot'] === 1)
        {   // 问答卡牌
            $tarotLevel = abs($this->astrInfo['tarot_level']);
            $data[] = [
                'type' => 4,
                'title' => '准了问答-卡牌能力分',
                'img' => $imgHost . '/mini/astrologer/test/1.png',
                'grade' => $this->astrInfo['tarot_grade'],
                'level_name' => $astrModel->astrLevelName2[4][$tarotLevel],
                'proportion' => ($astrModel->getAstrQuestionAnswerProportion($nowTime, 3, $tarotLevel) * 100) . '%',
                'protocol_url' => $apiHost . '/web/rule_tarot_grade',
            ];
        } else
        {
            if ($hint)
            {
                $hint .= '、';
            }
            $hint .= '准了问答卡牌';
        }

        if ($hint !== '')
        {
            $hint = '你没有通过' . $hint . '考试认证，暂时没有相关能力分，快去前往考试吧～';
        }

        $consultAccountInfo = (new Zlcr3ConsultAccount())->getInfoById($this->astrInfo['id']);
        $isConsult = $consultAccountInfo && $consultAccountInfo['consult_status'] === 1 ? 1 : 0;
        $res = [
            'list' => $data,
            'hint' => $hint,
            'is_consult' => $isConsult,//新增字段
        ];

        return show(200, '请求成功', $res);
    }
}
